package com.fire.social.controller;

import com.fire.social.entity.node.User;
import com.fire.social.service.RecommendService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;

/**
 * 推荐可能认识的朋友
 */

@Controller
public class RecommendUserController {

    @Autowired
    private RecommendService recommendService;

    @GetMapping("/recommend/user/byfriend")
    public String recommendFriendsByFriend(HttpServletRequest request, Map<String,Object> map){
        HttpSession session=request.getSession();
        User user =(User) session.getAttribute("user");
        if(user==null){
            return "login";
        }
        recommendService.recommendFriend(user, map);
        return "userlist";
    }
    @GetMapping("/recommend/user/bycontent")
    public String recommendFriendsByContent(HttpServletRequest request, Map<String,Object> map) {
        HttpSession session=request.getSession();
        User user =(User) session.getAttribute("user");
        if(user==null){
            return "login";
        }
        recommendService.recommendContent(user, map);
        return "userlist";
    }

    @GetMapping("/recommend/user/byhobby")
    public String recommendFriendsByHobby(HttpServletRequest request, Map<String,Object> map){
        HttpSession session=request.getSession();
        User user =(User) session.getAttribute("user");
        if(user==null){
            return "login";
        }
        recommendService.recommendHobby(user, map);
        return "userlist";
    }

}
